//
//  FZTabBarController.m
//  EnglishTalk
//
//  Created by CyonLeuPro on 15/5/25.
//  Copyright (c) 2015年 Feizhu Tech. All rights reserved.
//

#import "FZTabBarController.h"
#import "FZStyleSheet.h"
#import "FZNavigationController.h"
#import "SRCommonHeader.h"
#import <UIImage+Enhanced.h>


@interface FZTabBarController ()

@end

@implementation FZTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupData];
    [self setupView];
}

- (void)setViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers {
    [super setViewControllers:viewControllers];
    
    if ([viewControllers count] > 0) {
        NSInteger itemCount = [viewControllers count];
//        self.itemCount = itemCount;
        CGFloat itemSpace = 0;
        CGFloat itemWidth = floor((SCREEN_WIDTH - (itemCount -1) * itemSpace) / itemCount);
        self.tabBar.itemWidth = itemWidth;
        self.tabBar.itemSpacing = itemSpace;
    }
}

- (void)setupData
{
    
}

- (void)setupView {
    FZStyleSheet *css = [FZStyleSheet currentStyleSheet];
    self.tabBar.backgroundImage = [UIImage imageWithColor:css.tabBarBackgroundColor];
    self.tabBar.shadowImage = [UIImage imageWithColor:css.tabBarShadowColor size:CGSizeMake(1.0f, 0.5)];
    self.tabBar.itemPositioning = UITabBarItemPositioningFill;
}


- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return self.selectedViewController.preferredInterfaceOrientationForPresentation;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return self.selectedViewController.supportedInterfaceOrientations;
}

- (BOOL)shouldAutorotate {
    return self.selectedViewController.shouldAutorotate;
}

@end
